CFLAGS = -Wall -fpic -lm

randomtestadventurer.out: rngs.o dominion.o randomtestadventurer_tb.c
	gcc -o randomtestadventurer randomtestadventurer_tb.c dominion.o rngs.o $(CFLAGS)

randomtestcard.out: rngs.o dominion.o randomtestcard_tb.c
	gcc -o randomtestcard randomtestcard_tb.c dominion.o rngs.o $(CFLAGS)


tests: rngs.o dominion.o cardtest1.c cardtest2.c cardtest3.c cardtest4.c unittest1.c unittest2.c unittest3.c unittest4.c
	gcc -o unittest1 -g -fprofile-arcs -ftest-coverage unittest1_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o unittest2 -g -fprofile-arcs -ftest-coverage unittest2_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o unittest3 -g -fprofile-arcs -ftest-coverage unittest3_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o unittest4 -g -fprofile-arcs -ftest-coverage unittest4_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o cardtest1 -g -fprofile-arcs -ftest-coverage cardtest1_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o cardtest2 -g -fprofile-arcs -ftest-coverage cardtest2_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o cardtest3 -g -fprofile-arcs -ftest-coverage cardtest3_tb.c dominion.o rngs.o $(CFLAGS)
	gcc -o cardtest4 -g -fprofile-arcs -ftest-coverage cardtest4_tb.c dominion.o rngs.o $(CFLAGS)

unittestresults.out: rngs.o dominion.o cardtest1_tb.c cardtest2_tb.c cardtest3_tb.c cardtest4_tb.c unittest1_tb.c unittest2_tb.c unittest3_tb.c unittest4_tb.c
	rm -rf unittestresults.out
	rm -rf *.gcda *.gcno *.gcov
	echo "Running Unit Tests..." >> unittestresults.out
	gcc -o unittest1 -g -fprofile-arcs -ftest-coverage unittest1_tb.c dominion.o rngs.o $(CFLAGS)
	./unittest1 123 >> unittestresults.out
	echo "Coverage For Unit Test 1" >> unittestresults.out
	gcov -b ./unittest1.c >> unittestresults.out

	gcc -o unittest2 -g -fprofile-arcs -ftest-coverage unittest2_tb.c dominion.o rngs.o $(CFLAGS)
	./unittest2 123 >> unittestresults.out
	echo "Coverage For Unit Test 2" >> unittestresults.out
	gcov -b ./unittest2.c >> unittestresults.out

	gcc -o unittest3 -g -fprofile-arcs -ftest-coverage unittest3_tb.c dominion.o rngs.o $(CFLAGS)
	./unittest3 123 >> unittestresults.out
	echo "Coverage For Unit Test 3" >> unittestresults.out
	gcov -b ./unittest3.c >> unittestresults.out

	gcc -o unittest4 -g -fprofile-arcs -ftest-coverage unittest4_tb.c dominion.o rngs.o $(CFLAGS)
	./unittest4 123 >> unittestresults.out
	echo "Coverage For Unit Test 4" >> unittestresults.out
	gcov -b ./unittest4.c >> unittestresults.out

	gcc -o cardtest1 -g -fprofile-arcs -ftest-coverage cardtest1_tb.c dominion.o rngs.o $(CFLAGS)
	./cardtest1 123 >> unittestresults.out
	echo "Coverage For Card Test 1 (Village Card)" >> unittestresults.out
	gcov -b ./cardtest1.c >> unittestresults.out

	gcc -o cardtest2 -g -fprofile-arcs -ftest-coverage cardtest2_tb.c dominion.o rngs.o $(CFLAGS)
	./cardtest2 123 >> unittestresults.out
	echo "Coverage For Card Test 2 (Great Hall Card)" >> unittestresults.out
	gcov -b ./cardtest2.c >> unittestresults.out

	gcc -o cardtest3 -g -fprofile-arcs -ftest-coverage cardtest3_tb.c dominion.o rngs.o $(CFLAGS)
	./cardtest3 123 >> unittestresults.out
	echo "Coverage For Card Test 4 (Smithy Card)" >> unittestresults.out
	gcov -b ./cardtest3.c >> unittestresults.out

	gcc -o cardtest4 -g -fprofile-arcs -ftest-coverage cardtest4_tb.c dominion.o rngs.o $(CFLAGS)
	./cardtest4 123 >> unittestresults.out
	echo "Coverage For Card Test 4 (Council Room Card)" >> unittestresults.out
	gcov -b ./cardtest4.c >> unittestresults.out
	

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

runtests: testDrawCard 
	./testDrawCard &> unittestresult.out
	gcov dominion.c >> unittestresult.out
	cat dominion.c.gcov >> unittestresult.out


player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testInit testInit.exe *.gcov *.gcda *.gcno *.so


